import QtQuick
import QtQuick.Controls

Rectangle {
    width: 640
    height: 480

    ToolTip{
        id: tooltip
        anchors.centerIn: parent
    }
    Connections{
        target:actions
        function onLogs(str:string){
            tooltip.show(str, 3000);
        }
    }
    Grid{
        anchors.centerIn: parent
        columns: 4
        spacing: 20
        Button{
            width: 120
            height: 40
            text: "连接"
            onClicked: {
                actions.connectDevice();
            }
        }
        Button{
            width: 120
            height: 40
            text: "断开"
            onClicked: {
                actions.disconnectDevice();
            }
        }
        Button{
            width: 120
            height: 40
            text: "清空动作"
            onClicked: {
                actions.clearMaps();
            }
        }
        Button{
            width: 120
            height: 40
            text: checked ? "放钻阶段" : "抓钻阶段"
            checkable: true
            onClicked: {
                actions.waitPush(checked);
            }
        }
        Button{
            width: 120
            height: 40
            text: !checked ? "生成钻杆" : "隐藏钻杆"
            checkable: true
            onClicked: {
                actions.pushDrillrod(checked);
            }
        }
        Button{
            width: 120
            height: 40
            text: "抓手跟踪"
            checkable: true
            onClicked: {
                actions.startGripper(checked);
            }
        }
        Repeater{
            model: 2
            Item{
                width: 1
                height: 1
            }
        }

        Button{
            width: 120
            height: 40
            text: "抓手后旋"
            onPressed: {
                actions.gripperBackward(true);
            }
            onReleased: {
                actions.gripperBackward(false);
            }
            onCanceled: {
                actions.gripperBackward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "抓手前旋"
            onPressed: {
                actions.gripperForward(true);
            }
            onReleased: {
                actions.gripperForward(false);
            }

            onCanceled: {
                actions.gripperForward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "抓手正旋"
            onPressed: {
                actions.gripperRightward(true);
            }
            onReleased: {
                actions.gripperRightward(false);
            }

            onCanceled: {
                actions.gripperRightward(false);
            }

        }
        Button{
            width: 120
            height: 40
            text: "抓手负旋"
            onPressed: {
                actions.gripperLeftward(true);
            }
            onReleased: {
                actions.gripperLeftward(false);
            }

            onCanceled: {
                actions.gripperLeftward(false);
            }

        }
        Button{
            width: 120
            height: 40
            text: "抓手伸"
            onPressed: {
                actions.gripperStrech(true);
            }
            onReleased: {
                actions.gripperStrech(false);
            }

            onCanceled: {
                actions.gripperStrech(false);
            }

        }
        Button{
            width: 120
            height: 40
            text: "抓手缩"
            onPressed: {
                actions.gripperShrink(true);
            }
            onReleased: {
                actions.gripperShrink(false);
            }

            onCanceled: {
                actions.gripperShrink(false);
            }
        }

        Button{
            width: 120
            height: 40
            text: "推进架升"
            onPressed: {
                actions.pushFrameUpward(true);
            }
            onReleased: {
                actions.pushFrameUpward(false);
            }

            onCanceled: {
                actions.pushFrameUpward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "推进架降"
            onPressed: {
                actions.pushFrameDownward(true);
            }
            onReleased: {
                actions.pushFrameDownward(false);
            }

            onCanceled: {
                actions.pushFrameDownward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "推进架正旋"
            onPressed: {
                actions.pushFrameRightward(true);
            }
            onReleased: {
                actions.pushFrameRightward(false);
            }

            onCanceled: {
                actions.pushFrameRightward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "推进架负旋"
            onPressed: {
                actions.pushFrameLeftward(true);
            }
            onReleased: {
                actions.pushFrameLeftward(false);
            }

            onCanceled: {
                actions.pushFrameLeftward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "托盘升"
            onPressed: {
                actions.palletUpward(true);
            }
            onReleased: {
                actions.palletUpward(false);
            }

            onCanceled: {
                actions.palletUpward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "托盘降"
            onPressed: {
                actions.palletDownward(true);
            }
            onReleased: {
                actions.palletDownward(false);
            }

            onCanceled: {
                actions.palletDownward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "托盘右移"
            onPressed: {
                actions.palletRightward(true);
            }
            onReleased: {
                actions.palletRightward(false);
            }

            onCanceled: {
                actions.palletRightward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "托盘左移"
            onPressed: {
                actions.palletLeftward(true);
            }
            onReleased: {
                actions.palletLeftward(false);
            }

            onCanceled: {
                actions.palletLeftward(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "支撑油缸松"
            onPressed: {
                actions.drillFrameUnwind(true);
            }
            onReleased: {
                actions.drillFrameUnwind(false);
            }

            onCanceled: {
                actions.drillFrameUnwind(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "支撑油缸夹"
            onPressed: {
                actions.drillFrameShrink(true);
            }
            onReleased: {
                actions.drillFrameShrink(false);
            }

            onCanceled: {
                actions.drillFrameShrink(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "钻杆框升"
            onPressed: {
                actions.drillFrameUpward(true);
            }
            onReleased: {
                actions.drillFrameUpward(false);
            }

            onCanceled: {
                actions.drillFrameUpward(false);
            }
        }

        Button{
            width: 120
            height: 40
            text: "钻杆框降"
            onPressed: {
                actions.drillFrameDownward(true);
            }
            onReleased: {
                actions.drillFrameDownward(false);
            }

            onCanceled: {
                actions.drillFrameDownward(false);
            }
        }

        Button{
            width: 120
            height: 40
            text: "推进"
            onPressed: {
                actions.pushDrill(true);
            }
            onReleased: {
                actions.pushDrill(false);
            }

            onCanceled: {
                actions.pushDrill(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "起拔"
            onPressed: {
                actions.pullDrill(true);
            }
            onReleased: {
                actions.pullDrill(false);
            }

            onCanceled: {
                actions.pullDrill(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "前夹持合"
            onPressed: {
                actions.frontFolderClose(true);
            }
            onReleased: {
                actions.frontFolderClose(false);
            }

            onCanceled: {
                actions.frontFolderClose(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "前夹持开"
            onPressed: {
                actions.frontFolderOpen(true);
            }
            onReleased: {
                actions.frontFolderOpen(false);
            }

            onCanceled: {
                actions.frontFolderOpen(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "后夹持合"
            onPressed: {
                actions.backFolderClose(true);
            }
            onReleased: {
                actions.backFolderClose(false);
            }

            onCanceled: {
                actions.backFolderClose(false);
            }
        }
        Button{
            width: 120
            height: 40
            text: "后夹持开"
            onPressed: {
                actions.backFolderOpen(true);
            }
            onReleased: {
                actions.backFolderOpen(false);
            }

            onCanceled: {
                actions.backFolderOpen(false);
            }
        }
    }
}
